package com.meal.test.controller;

/**
 * @Title: MessageController
 * @Description: 点赞前端控制层
 * @Author yangzhanghui
 * @Date 2020/5/423:32
 * @Version v1.0
 */

import com.meal.entity.base.BaseController;
import com.meal.test.model.PraiseRecordVO;
import com.meal.test.model.RocketConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.function.ServerResponse;

import javax.annotation.Resource;
@RequestMapping("/message")
public class MessageController extends BaseController {

    @Resource
    private RocketMQTemplate rocketMQTemplate;

    @PostMapping("/praise")
    public ServerResponse praise(@RequestBody PraiseRecordVO vo) {
        rocketMQTemplate.sendOneWay(RocketConstant.Topic.PRAISE_TOPIC, MessageBuilder.withPayload(vo).build());
        return ServerResponse.ok().build();
    }
}